package com.pocket.demo.base.exception;

import com.pocket.demo.base.enums.MsgCodeEnum;

/**
 * @Author zhao.zq
 * @Date 2023/8/28 21:00
 **/
public class BusinessException extends RuntimeException {
    private String debug;
    private MsgCodeEnum msgCodeEnum;
    private Object[] args;
    private Object detail;
    private BusinessException fromException;

    public BusinessException() {}

    public BusinessException(MsgCodeEnum msgCodeEnum, Object... args) {
        this(null, msgCodeEnum, args);
    }

    public BusinessException(String debug, MsgCodeEnum msgCodeEnum, Object... args) {
        this.debug = debug;
        this.msgCodeEnum = msgCodeEnum;
        this.args = args;
    }

    public MsgCodeEnum getMsgCodeEnum() {
        return this.msgCodeEnum;
    }

    public void setMsgCodeEnum(MsgCodeEnum msgCodeEnum) {
        this.msgCodeEnum = msgCodeEnum;
    }

    public Object[] getArgs() {
        return this.args;
    }

    public void setArgs(Object[] args) {
        this.args = args;
    }

    public Object getDetail() {
        return this.detail;
    }

    public BusinessException setDetail(Object detail) {
        this.detail = detail;
        return this;
    }

    public String getDebug() {
        return this.debug;
    }

    public void setDebug(String debug) {
        this.debug = debug;
    }

    public BusinessException getFromException() {
        return this.fromException;
    }

    public void setFromException(BusinessException fromException) {
        this.fromException = fromException;
    }

    @Override
    public String getMessage() {
        return this.msgCodeEnum.getMsgKey();

    }
}
